QuickOPC User's Guide and Reference
OPC-UA Host and Endpoint Dialog
View with Navigation Tools
Features > User Interface > OPC Common Dialogs > OPC-UA Common Dialogs > OPC-UA Host and Endpoint Dialog
In This Topic

General

Icon:

With UAHostAndEndpointDialog, your application can integrate a dialog box from which the user can select a host (computer) and an endpoint of OPC-UA server residing on it. This dialog box combines functions of the Computer Browser Dialog and OPC-UA Endpoint Dialog -  into a single dialog.

In addition, the user can add Host nodes in case the particular computer is not visible on the network, or add OPC-UA Endpoint nodes in case the OPC_UA Server is known to exist but is not returned by OPC-UA discovery feature.

Here is an example of OPC-UA Host and Endpoint dialog in action:

.NET

// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UAHostAndEndpointDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var hostAndEndpointDialog = new UAHostAndEndpointDialog
            {
                EndpointDescriptor = {Host = "opcua.demo-this.com"}
            };

            DialogResult dialogResult = hostAndEndpointDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, 
                $"HostElement: {hostAndEndpointDialog.HostElement}\r\n" +
                $"DiscoveryElement: {hostAndEndpointDialog.DiscoveryElement}");
        }
    }
}

COM

// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UAHostAndEndpointDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UAHostAndEndpointDialogPtr HostAndEndpointDialogPtr(__uuidof(UAHostAndEndpointDialog));

            //
            HostAndEndpointDialogPtr->EndpointDescriptor->Host = L"opcua.demo-this.com";

            // 
            DialogResult dialogResult = HostAndEndpointDialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _HostElementPtr hostElementPtr = HostAndEndpointDialogPtr->HostElement;
                _tprintf(_T("HostElement: %s\n"), (hostElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(hostElementPtr->ToString));
                _UADiscoveryElementPtr discoveryElementPtr = HostAndEndpointDialogPtr->DiscoveryElement;
                _tprintf(_T("DiscoveryElement: %s\n"), (discoveryElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(discoveryElementPtr->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}

 

Advanced

If you want to change the parameters of the client object the component uses to perform its OPC operations, you can use the ClientSelector Property.

 

See Also